package com.itheima.chapter07.exception;

public class trycatch {
    public static void main(String[] args) {
        int[] arr =null;
        try {
            printArr(arr);//有可能异常的代码
        } catch (NullPointerException e) {
            System.out.println("不能为空");//出现异常这样做
        }
    }
    private static void printArr(int[] arr){

            for (int i = 0; i < arr.length; i++) {
                System.out.println(arr[i]);
            }

    }
}
